package com.vincent.rocketmqdemo.listener;

import com.aliyun.openservices.ons.api.Action;
import com.aliyun.openservices.ons.api.ConsumeContext;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageListener;
import com.aliyun.openservices.ons.api.impl.util.MsgConvertUtil;

public class MqMsgListener implements MessageListener {

    @Override
    public Action consume(Message message, ConsumeContext consumeContext) {
        System.out.println("消息监听");
        String messagestr = MsgConvertUtil.bytes2String(message.getBody(), "UTF-8");
        System.out.println(messagestr);
//        String a = JSONObject.parseObject(message.getBody(), String.class);
//        System.out.println(a);
        return Action.CommitMessage;
    }
}
